<?php 
namespace Mobile\Controller;

use Home\Logic\UsersLogic;
use Think\Page;
use Think\Verify;

class DiscoveryController extends MobileBaseController{
	
	public $user_id = 0;
	public $user = array();

	public function _initialize(){
		parent::_initialize();
		if(session('?user')){
			$user = session('user');
			$user = M('users')->where("user_id = {$user['user_id']}")->find();
			session('user',$user);
			$this->user = $user;
			$this->user_id = $user['user_id'];
			$this->assign('user', $user); //存储用户信息
		}
		$nologin = array(
            'login', 'pop_login', 'do_login', 'logout', 'verify', 'set_pwd', 'finished',
            'verifyHandle', 'reg', 'send_sms_reg_code', 'find_pwd', 'check_validate_code',
            'forget_pwd', 'check_captcha', 'check_username', 'send_validate_code', 'express',
        );
        if (!$this->user_id && !in_array(ACTION_NAME, $nologin)) {
            header("location:" . U('Mobile/User/login'));
            exit;
        }
	}


	public function index(){
		

		//好货 = 推荐
		//工厂 = 热卖+新品+sort=1000
		//新品 = 新品
		//卖点 = 热卖
		//其他 = 推荐+热卖+新品+sort=1000



        //查询五个数据
        $where['article_id'] = array('in', array(1239,1242,1243,1244,1245)) ;
        $articleList = M('article')->where($where)->select();
		// $type = $_GET['type'];
		$article_id = I("article_id",'1239');
        $article = M('article')->where('article_id ='.$article_id)->find();


		$goods = M('goods')->where($where)->order('sort desc')->limit(3)->cache(true,TPSHOP_CACHE_TIME)->select();
 
		
		$this->assign('goods',$goods);
		$this->assign('article',$article);
		$this->assign('articleList',$articleList);
		$this->display();


	}


}



?>